package com.capa.ui.memo

import android.app.Application
import android.icu.text.DateFormat
import androidx.lifecycle.MutableLiveData
import com.capa.basic.BaseViewModel
import com.capa.model.Memo
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale

open class MemoViewModel(application: Application): BaseViewModel(application) {
   val  memos : MutableLiveData<List<Memo>> = MutableLiveData()
    var memosList = mutableListOf<Memo>()
    init {
        memosList.add(Memo(1,"word1","word1", parseDate("2015-7-9")))
        memosList.add(Memo(2,"word2","word2", parseDate("2015-7-10")))
        memosList.add(Memo(3,"word2","word2", parseDate("2015-7-11")))
        memos.value = ArrayList(memosList)
    }
}

fun parseDate(dateString: String): Date {
    return SimpleDateFormat("yyyy-M-d", Locale.getDefault()).parse(dateString)
}

